import java.util.ArrayList;

public class reorder_list {
    public void reorderList(ListNode head) {
        ArrayList<ListNode> list= new ArrayList<>();
        ListNode cur=head;
        while(cur!=null){
            list.add(cur);
            cur=cur.next;
        }
        int front=0,back=list.size()-1;
        while(front<back){
            list.get(front).next=list.get(back);
            front++;
            if(front==back) break;
            list.get(back).next=list.get(front);
            back--;
        }
        list.get(front).next=null;
    }
}
